//
//  SHBaseModel.m
//  UI_CarHome
//
//  Created by dllo on 15/10/22.
//  Copyright (c) 2015年 沈浩. All rights reserved.
//

#import "SHBaseModel.h"

@implementation SHBaseModel

- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        // 进行KVC的赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (NSMutableArray *)baseModelByArr:(NSArray *)arr
{   // 先初始化容器arr
    NSMutableArray *modelArr = [NSMutableArray array];
    //
    for (NSDictionary *dic in arr) {
        @autoreleasepool {
            // 通过遍历构造器来创建对象
            id model = [[self class] baseModelWithDic:dic];
            
            [modelArr addObject:model];
        }
    }
    return modelArr;
}

+ (instancetype)baseModelWithDic:(NSDictionary *)dic
{
    // 通过多态创建对象
    id model = [[[[self class] alloc] initWithDic:dic] autorelease];
    return model;
}


- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}


@end
